export let methods: Array<{ method: string; name: string; prefix: string; handler: () => void; url?: string }> = [];

export enum METHOD {
	GET = 'get',
	POST = 'post',
	PUT = 'put',
	DELETE = 'delete',
	OPTIONS = 'options',
	PATCH = 'patch',
}
/**
 * 路由装饰器
 * @param method 可选 请求方式，get,post等
 * @param url 可选 自定义url，如 :id，/module/method，/aaabbb等
 */
export function api({
	method = METHOD.GET,
	url = '',
}: {
		method?: METHOD;
		url?: string;
	}) {
	return (target: any, name: string, desc: PropertyDescriptor) => {
		// debug(target.constructor.name);
		const prefix = target.constructor.name;
		methods.push({
			method,
			prefix,
			name,
			handler: target[name],
			url,
		});
	};
}
